package com.sgb.kjwl.view.ui.adapter.self.packers;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.self.SelfTeamDeviceEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class TeamDeviceAdapter extends BaseRecycleAdapter<SelfTeamDeviceEntity> {

    TextView tv_number;

    public TeamDeviceAdapter(Context context, List<SelfTeamDeviceEntity> datas) {
        super(context, R.layout.item_team_device, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final SelfTeamDeviceEntity entity) {
        holder.setBinding(BR.viewModel, entity);
        tv_number = holder.getItem().findViewById(R.id.tv_number);
       ImageView imgLogo= holder.itemView.findViewById(R.id.img_logo);
        RequestOptions options = new RequestOptions()
                .placeholder(R.mipmap.packer_avatar)
                .transforms(new CenterCrop(), new RoundedCorners(8));
        if (!TextUtils.isEmpty(entity.getPicture())){
            String[] split = entity.getPicture().split(",");
            Glide.with(context).load(split[0]).apply(options).into(imgLogo);
        }else {
            Glide.with(context).load(R.mipmap.mechanical).apply(options).into(imgLogo);
        }
        if (TextUtils.isEmpty(entity.getCountNum())){
            tv_number.setVisibility(View.GONE);
        }else {
            tv_number.setVisibility(View.VISIBLE);
        }


    }


}
